Add E2E coverage for purchase on both checkout forms, SKU identifier, disabled events, and settings form - #638
Merged
Merged
Conversation
Place an order through the woocommerce/checkout block and assert the purchase event reports the order's items, quantities, variation, totals, shipping, and transaction id. The purchase event is built server-side from the order, so its data does not vary by checkout type, but the block checkout form and the block order-confirmation page (where woocommerce_thankyou fires) can break independently of the classic checkout across store settings and WooCommerce versions. Verifying the block path on its own guards that happy path.
Cover the merchant setting that switches product reporting from the WooCommerce id to the SKU. With the identifier set to SKU, assert that the view_item event reports the product's SKU, that it falls back to the "#id" form when a product has no SKU, and that a Store API add to cart on the block storefront also reports the SKU. Let the test settings endpoint accept a product identifier override and let createSimpleProduct() take field overrides so a product can be created with a SKU. Both default to the previous behavior.
Assert that no ecommerce events reach GA when every event toggle is off (while the tracking scripts still load), and that disabling only add to cart leaves the other events firing. Let the test settings endpoint accept per-event tracking toggles so a test can switch individual events off.
Assert the integration settings form renders the product identifier select with its options, the tracking id field, and every remaining control defined by init_form_fields, so a dropped control or a mislabeled identifier option is caught.
The classic spec's purchase test submitted the default checkout page, which is the block checkout, so it duplicated the block purchase test in the blocks spec. Drive it through the classic [woocommerce_checkout] shortcode form instead (a wc-ajax=checkout submission rather than the Store API) via a new classicCheckout() helper. The order-received confirmation is rendered by the block theme's Order Confirmation template for both forms, so that surface stays shared; a true classic thankyou template would require a classic theme, which the suite does not use.
checkout() always navigates to the default checkout page, which has been the block checkout in this suite, so its classic form branch could never run. The classic form path is now owned by classicCheckout().
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe test-data REST handler now accepts JSON request parameters, validates supported Google Analytics product and toggle values, applies valid overrides to defaults, and persists the resulting settings. ChangesGA test settings
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
This PR extends the E2E suite to cover several happy paths that are sensitive to store settings and to WP/WC version changes, plus the test infrastructure needed to drive them.
woocommerce/checkoutblock, and the classic spec's purchase test now drives the order through the[woocommerce_checkout]shortcode form (awc-ajax=checkoutsubmission rather than the Store API) via a newclassicCheckout()helper, so the two purchase tests exercise the two different checkout forms instead of duplicating each other. Both assert the purchase event reports the order's items, quantities, variation, totals, shipping, and transaction ID. The order-received confirmation is rendered by the block theme's Order Confirmation template for both forms; a true classic thankyou template would require a classic theme, which the suite does not use. The now-dead classic form branch inside thecheckout()helper (unreachable since the default checkout page is the block checkout) is removed, with the classic path owned byclassicCheckout().ga_product_identifiersetting to SKU and assert thatview_itemreports the product SKU, falls back to the#idform when a product has no SKU, and that a Store API add to cart on the block storefront also reports the SKU (a separate, server-resolved identifier path).window.ga4w.settings.events), and that disabling only add to cart leaves the other events firing.init_form_fields(), so a dropped control or a mislabeled identifier option is caught.tests/e2e/test-data) now accepts a product identifier override, and the per-event tracking toggles through the request body, andcreateSimpleProduct()/setSettings()accept overrides. All default to the previous behavior, so existing specs are unaffected.Checks:
Detailed test instructions:
npm run wp-env:upnpm run test:e2ehttps://github.com/woocommerce/woocommerce-google-analytics-integration/actions/runs/30002235049/job/89189882792
Changelog entry
No issues found.